package cn.rkylin.oms.common.event.message;

import cn.rkylin.oms.common.event.BusinessEvent;
import cn.rkylin.oms.common.event.EventTypeCodeEnum;

import java.util.Date;
import java.util.EnumMap;
import java.util.List;

public class MessageEvent extends BusinessEvent {

    private EventTypeCodeEnum type;
    private final List<MessageReceiver> receivers;
    private final MessageDefinition definition;
    private final EnumMap<MessageTemplateVariable, Object> variables;
    private final Date creationTime;

    public MessageEvent(EventTypeCodeEnum type, List<MessageReceiver> receivers, MessageDefinition definition, EnumMap<MessageTemplateVariable, Object> variables) {
        this.type = type;
        this.receivers = receivers;
        this.definition = definition;
        this.variables = variables;
        this.creationTime = new Date();
    }

    public List<MessageReceiver> getReceivers() {
        return receivers;
    }

    public MessageDefinition getDefinition() {
        return definition;
    }

    public EnumMap<MessageTemplateVariable, Object> getVariables() {
        return variables;
    }

    public Date getCreationTime() {
        return creationTime;
    }

    @Override
    public EventTypeCodeEnum getAssociatedType() {
        return this.type;
    }
}
